// alle vierkantjes tracken
// als vierkantje in frame weinig is verschoven is dat vorige gezicht
// alleen nieuwe vierkantjes aan linkerkant
// history bijhouden
// vierkantje mag x aantal frames gemist worden


////////////////////////////////////////////////////////////////////////
// a3.cpp
//
// Third assignment for Advanced Multimedia Computing
//
// T. Kostelijk & F. Huizinga
//     0418889      0418862
//
////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>

int main(int argc, char **argv) {
	// load image 
    IplImage *img = cvLoadImage(argv[1]);

    if(!img){
        printf("Could not load image file: %s\n",argv[1]);
        exit(0);
    }

    // initialize video writer
    CvVideoWriter *videowriter = cvCreateVideoWriter("out.avi", CV_FOURCC('M','J','P','G'), 20, cvSize(img->width, img->height));
    cvWriteFrame(videowriter, img);
    cvWriteFrame(videowriter, img);
    cvWriteFrame(videowriter, img);
    cvWriteFrame(videowriter, img);
    cvWriteFrame(videowriter, img);
    cvWriteFrame(videowriter, img);
    cvWriteFrame(videowriter, img);
    
	// Show the final image
    cvNamedWindow("mainWin", CV_WINDOW_AUTOSIZE); 
	cvShowImage("mainWin", img );
	cvWaitKey(0);

	// clear the memory
	cvReleaseImage( &img );
    cvReleaseVideoWriter( &videowriter );

    return 0;
}
